package com.dkt.doctor;

import com.dkt.entity.UserDoctorInfo;
import com.dkt.entity.UserOrgInfo;
import com.platform.common.dao.impl.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by litai on 2017/6/17.
 */
@Repository
public class DoctorDaoImpl extends BaseDao<UserDoctorInfo> implements DoctorDao {

    public List<UserDoctorInfo> getList(RequestBeanP10012 bean) {

        List<UserDoctorInfo> list = new ArrayList<UserDoctorInfo>();
        StringBuilder whereSql = new StringBuilder("from UserDoctorInfo ui where ui.doctorId in (select ud.doctorId from UserDoctorRelation ud where ud.departmentId = ?) ");
        List<String> params = new ArrayList<String>();

        params.add(bean.getDeptId());

        if (!bean.getAllDoctor()) {

            whereSql.append(" and ui.doctorWay = ? ");
            params.add("1");
        }

        whereSql.append(" order by ui.doctorWay desc ");

        list = getListByHQL(whereSql.toString(), null, params.toArray());

        return list;
    }

}
